﻿using Medianamik.Core.DAL.Repositories;

namespace Medianamik.Core.DAL
{
    internal class SubsonicDALProvider : IDALProvider
    {
        private SubsonicNodeTypeDALProvider _nodeTypeDALProvider;
        public INodeTypeDALProvider NodeTypeDALProvider
        {
            get
            {
                if (_nodeTypeDALProvider == null)
                {
                    _nodeTypeDALProvider = new SubsonicNodeTypeDALProvider(new NodeTypeRepository());
                }
                return _nodeTypeDALProvider;
            }
        }

        private SubsonicNodeDALProvider _nodeDALProvider;
        public INodeDALProvider NodeDALProvider
        {
            get
            {
                if (_nodeDALProvider == null)
                {
                    _nodeDALProvider = new SubsonicNodeDALProvider();
                }
                return _nodeDALProvider;
            }
        }

        private SubsonicConfigDALProvider _configDALProvider;
        public IConfigDALProvider ConfigDALProvider
        {
            get
            {
                if (_configDALProvider == null)
                {
                    var dataTypeRepo = new DataTypeRepository();
                    var mkControlRepo = new MedianamikControlRepository(dataTypeRepo);
                    _configDALProvider = new SubsonicConfigDALProvider(dataTypeRepo, mkControlRepo);
                }
                return _configDALProvider;
            }

        }

        private SubsonicSecurityDALProvider _securityDALProvider;
        public ISecurityDALProvider SecurityDALProvider
        {
            get
            {
                if (_securityDALProvider == null)
                {
                    _securityDALProvider = new SubsonicSecurityDALProvider();
                }
                return _securityDALProvider;
            }
        }
    }
}
